using System;
using System.Collections.Generic;
using System.Text;
using ENTITIES;
using DAL;
using Utility;


namespace BUS
{
   public class LoaiMHBUS
    {
         public static void Insert(TBLoaiMH mh)
        {
            LoaiMHDAL mhDAL = new LoaiMHDAL();
            mhDAL.Insert(mh);
        }
        public static void Update(TBLoaiMH mh)
        {
            LoaiMHDAL mhDAL = new LoaiMHDAL();
            mhDAL.Update(mh);
        }
        public static void Delete(int iD)
        {
            LoaiMHDAL mhDAL = new LoaiMHDAL();
            mhDAL.Delete(iD);
        }
        public static tbLoaiMHCollection Get(string where,
            int pageindex,
            int pagesize,
            string orderby,
            string orderdirection,
            out int total)
        {
            LoaiMHDAL mhDAL = new LoaiMHDAL();
            return mhDAL.Get(where, pageindex, pagesize, orderby, orderdirection, out total);
        }
        public static tbLoaiMHCollection GetAll()
        {
            int total = 0;
            Criteria cri = new Criteria();
            LoaiMHDAL mhDAL = new LoaiMHDAL();
            return mhDAL.Get(cri.Criter, 0, 0, tbLoaiMHColumns.MaLoaiMH.ToString(), OrderDirection.ASC.ToString(), out total);
        }
        public static TBLoaiMH GetByID(int iD)
        {
            int total = 0;
            Criteria cri = new Criteria();
            cri.add(Condition.AND, tbLoaiMHColumns.MaLoaiMH.ToString(), Condition.EQUAL, iD);
            LoaiMHDAL mhDAL = new LoaiMHDAL();
            tbLoaiMHCollection loaimathangcollection = mhDAL.Get(cri.Criter,
                  0, 0, tbLoaiMHColumns.MaLoaiMH.ToString(), OrderDirection.ASC.ToString(), out total);
            if (loaimathangcollection.Count > 0)
                return loaimathangcollection[0];
            return null;
        }
        public static tbLoaiMHCollection GetLimited(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            LoaiMHDAL mhDAL = new LoaiMHDAL();
            return mhDAL.Get(cri.Criter, 1, number,
             tbLoaiMHColumns.MaLoaiMH.ToString(), OrderDirection.DESC.ToString(), out total);
        }
        public static tbLoaiMHCollection GetPromotion(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            LoaiMHDAL mhDAL = new LoaiMHDAL();
            return mhDAL.Get(cri.Criter, 1, number,
               tbLoaiMHColumns.MaLoaiMH.ToString(), OrderDirection.DESC.ToString(), out total);
        }
    }
    }

